export default () => {
	/**
	 * Set data to local storage
	 * @param data
	 */
	function set(data) {
		if (typeof data == "object") {
			data = JSON.stringify(data);
		}
		localStorage.setItem("data", data);
	}

	/**
	 * Get data from local storage
	 * @returns {any|null}
	 */
	function get() {
		const data = localStorage.getItem("data");
		if (data) {
			return JSON.parse(data);
		}
		return null;
	}

	/**
	 * Remove data from local storage
	 */
	function remove() {
		localStorage.removeItem("data");
	}

	/**
	 * Clear local storage
	 */
	function clear() {
		localStorage.clear();
	}
	return {
		set,
		get,
		remove,
		clear
	};
};
